#ifndef __MCS__UTILITY_PARSERS__HPP
#define __MCS__UTILITY_PARSERS__HPP

#include "InputStream.hpp"
#include "ParsingErrorException.hpp"

class StringParser
{
public:
	StringParser(InputStream * stream)
		: string_()
		, location_()
	{
		location_ = parse(stream);
	}

	String string() const { return string_; }
	SourceLocation const & location() const { return location_; }
private:
	String string_;
	SourceLocation location_;

	SourceLocation parse(InputStream * stream);
};

class NameParser
{
public:
	NameParser(InputStream * stream)
		: name_()
		, location_()
	{
		location_ = parse(stream);
	}
	
	String name() const { return name_; }
	SourceLocation const & location() const { return location_; }
private:
	String name_;
	SourceLocation location_;

	SourceLocation parse(InputStream * stream);
};

//TODO: add support for real numbers
class NumberParser
{
public:
	NumberParser(InputStream * stream)
		: intVal_(0)
		, location_()
	{
		location_ = parse(stream);
	}

	int intValue() const { return intVal_; }
	SourceLocation const & location() const { return location_; }
private:
	int intVal_;
	SourceLocation location_;

	SourceLocation parse(InputStream * stream);
};

class OperatorParser
{
public:
	OperatorParser(InputStream * stream)
		: string_()
		, location_()
	{
		location_ = parse(stream);
	}

	String string() const { return string_; }
	SourceLocation const & location() const { return location_; }
private:
	String string_;
	SourceLocation location_;

	SourceLocation parse(InputStream * stream);
};

#endif //__MCS__STRING_PARSER__HPP
